﻿package mortal.game.view.heroArena.view
{
    import com.mui.controls.*;
    import extend.language.*;
    import fl.data.*;
    import flash.display.*;
    import flash.events.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.view.common.*;
    import mortal.game.view.heroArena.renderer.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class HeroArenaInvateResponseWin extends BaseWindow
    {
        private var _invateList:GTileList;
        private static var _instance:HeroArenaInvateResponseWin;

        public function HeroArenaInvateResponseWin(param1:ILayer = null)
        {
            super(param1);
            setSize(342, 274 - 45);
            title = Language.getString(41548);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.pushUIToDisposeVec(UIFactory.bg(9, 37, 326, 188, this));
            this._invateList = UIFactory.tileList(20, 38, 315, 190, this);
            this._invateList.columnWidth = 315;
            this._invateList.rowHeight = 62;
            this._invateList.horizontalGap = 0;
            this._invateList.verticalGap = 0;
            this._invateList.setStyle("skin", new Bitmap());
            this._invateList.setStyle("cellRenderer", HeroArenaInvateResponseRenderer);
            this.addListeners();
            return;
        }// end function

        private function addListeners() : void
        {
            Dispatcher.addEventListener(EventName.HeroArenaUpdateInvateList, this.onUpdateInvateList);
            NetDispatcher.addCmdListener(ServerCommand.HeroArenaGetTeamInvate, this.onUpdateInvateList);
            return;
        }// end function

        private function removeListeners() : void
        {
            Dispatcher.removeEventListener(EventName.HeroArenaUpdateInvateList, this.onUpdateInvateList);
            NetDispatcher.removeCmdListener(ServerCommand.HeroArenaGetTeamInvate, this.onUpdateInvateList);
            return;
        }// end function

        private function onUpdateInvateList(event:DataEvent) : void
        {
            if (Cache.instance.heroArena.invateList.length == 0)
            {
                this.hide();
            }
            else
            {
                this.updateInfoList();
            }
            return;
        }// end function

        private function updateInfoList() : void
        {
            var _loc_1:* = new DataProvider();
            var _loc_2:* = Cache.instance.heroArena.invateList;
            _loc_1.addItems(_loc_2);
            this._invateList.dataProvider = _loc_1;
            this._invateList.drawNow();
            return;
        }// end function

        private function onClickHandler(event:MouseEvent) : void
        {
            return;
        }// end function

        override public function show(param1:int = 0, param2:int = 0) : void
        {
            super.show();
            this.updateInfoList();
            return;
        }// end function

        override public function hide() : void
        {
            Cache.instance.heroArena.invateList.length = 0;
            super.hide();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._invateList.dispose();
            this._invateList = null;
            this.removeListeners();
            return;
        }// end function

        public static function get instance() : HeroArenaInvateResponseWin
        {
            if (_instance == null)
            {
                _instance = new HeroArenaInvateResponseWin;
            }
            return _instance;
        }// end function

        public static function isViewShow() : Boolean
        {
            return _instance && !_instance.isHide;
        }// end function

    }
}
